<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            position: absolute;
            left: 0;
            width: 100px;
            height: 100px;
            background-color: pink;
        }
        
        span {
            position: absolute;
            left: 0;
            top: 200px;
            display: block;
            width: 150px;
            height: 150px;
            background-color: purple;
        }
    </style>
</head>

<body>
    <button>点击夏雨荷才走</button>
    <span>夏雨荷</span>
</body>

<script>
    function animate(obj, x) {
        clearInterval(obj.timer);
        obj.timer = setInterval(function() {
            if (obj.offsetLeft > x) {
                clearInterval(obj.timer);
            } else {
                let move = Math.ceil((x - obj.offsetLeft) / 10);
                obj.style.left = obj.offsetLeft + move + 'px';
            }
        }, 15);
    };

    let button = document.querySelector('button');
    let span = document.querySelector('span');
    button.addEventListener('click', function() {
        animate(span, 200);
    });
</script>

</html>